<template>
  <div>
    <FilterTable
      ref="table"
      columnsRef="zjUploadFile"
      height="auto"
      :columns="columns"
      :isSelectColumn="false"
      :onColumnsChange="columns => (this.columns = columns)"
      :dataSource="list"
      :onSyncTableData="syncTableFun"
      :isPagination=false
    />
    <div style="height:60px"></div>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <multiuse-button @click="closeDrawer(1)">关 闭</multiuse-button>
    </div>
  </div>
</template>
<script>
import { checkExistsByOemId } from '@/api/technicalReportManagement/fileList.js';
import moment from 'moment';
import { dictionary } from '@/utils/dictMixin';
export default {
  data() {
    this.saveData = null;
    this.table = null;
    return {
      form: {
        fileList: []
      },
      list: [],
      syncList: [],
      columns: this.createdTable(),
      emitList: []
    };
  },
  mixins: [dictionary],
  props: ['rowData'],
  created() {
    console.log('编辑ID',this.rowData)
    this.checkExistsByOemId(this.rowData);
  },
  mounted() {
    this.table = this.$refs.table.$refs.pageTable;
  },
  methods: {
    createdTable() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          fixed: 'left',
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },

        {
          title: '附件标题',
          dataIndex: 'title',
          showOverflowTooltip: true,
          sorter: true,
          filter: true,
          filterType: 'input',
          render: p => {
            return (
              <a style="color:#bb0a30" href={p.row.fileUrl} target="_blank" download={p.row.title}>
                {p.row.title}
              </a>
            );
          }
        },
        // {
        //   title: '附件类型',
        //   dataIndex: 'fileType',
        //   sorter: true,
        //   filter: true,
        //   filterType: 'checkbox',
        //   filterItems: this.createDictList('7077', 1),
        //   dictItems: this.createDictList('7077', 1),
        //   render: p => {
        //     return <span>{this.createDictText(p.row.fileType, '7077', 1)}</span>;
        //   }
        // },
        {
          title: '上传时间',
          dataIndex: 'createdAt',
          sorter: true,
          filter: true,
          filterType: 'date-range'
        },
        // {
        //   title: '备注',
        //   dataIndex: 'remark',
        //   sorter: true,
        //   filter: true,
        //   filterType: 'input',
        //   editable: false,
        //   defaultEditable: false,
        //   editType: 'text'
        // }
      ];
    },
    async checkExistsByOemId(id) {
      let res = await checkExistsByOemId({ oemId: id });
      this.emitList = res.data || [];
      if (this.emitList.length > 0) {
        this.table.EXECUTE_INSERT(this.emitList);
      }
    },
    syncTableFun(val) {
      this.syncList = val;
    },

    async closeDrawer(type) {
      if (type == 1) {
        this.$emit('close');
      }
    }
  }
};
</script>
